import re

#Router ID: 4.4.4.4          Address: 47.1.1.4  Neighbor is up for 00:00:51
#Router ID: (\S+) +Address: (\S+).+Neighbor is up for (\S+) 

regex=r'Router ID: (\S+) +Address: (\S+).+Neighbor is up for (\S+)'


with open(r'c:\tools\ospf_peer.txt') as f:
	ospf_peer=f.read()
	print(ospf_peer)

#不使用Flag标识符
print(re.search(regex,ospf_peer))

#使用Flag标识符
print(re.search(regex,ospf_peer,re.DOTALL).groups())